/**
 * Created by alan on 2017/5/5.
 * 数据字典
 */
Ext.define('Admin.view.sys.dict', {
	extend: "Admin.common.container.BaseContainer",
	xtype: 'dict',
	//起别名
	alias: 'dict',
	requires: [
		'Admin.store.sys.Dict'
	],
	controller: 'dictController',
	userCLs: 'big-100 small-100',
	layout: 'fit',
	width: '100%',
	height: 200,
	items: [
		{
			title: '数据字典',
			xtype: 'baseGridPanel',
			border:true,
			reference: 'dictGrid',
			tbar: [
				{
					xtype: "combobox",
					maxWidth: 220,
					fieldLabel: "类型",
					labelWidth: 50,
					reference: "type",
					forceSelect: true,
					margin: '10 0 10 0',
					labelAlign:'right',
					editable: false,
					name: '时间维度',
	
					value: 'day',
					valueField: 'type',
					displayField: 'name',
					selectionType: 'day',
					selectionMode: 'SINGLE',
					listeners: {
						change: 'onSelectionTypeChange'
					},
	
					store: {
						type: 'array',
						fields: ['type', 'name'],
						data: [
							['month', '月'],
							['period', '旬'],
							['day', '日']
						]
					}
	
				}, {
					xtype: "textfield",
					maxWidth: 220,
					fieldLabel: "描述",
					margin: '10 0 10 0',
					labelAlign:'right',
					labelWidth: 50,
					reference: "description"
				},
				{
					xtype: "button",
					text: "查询",
					iconCls: 'x-fa  fa-file-o',
					margin: '10 0 10 10',
					handler: 'check',
					// style: 'background-color:#108ee9; border-radius:4px;-webkit-border-radius: 4px;',
					style: 'border-radius:4px;-webkit-border-radius: 4px;'
				},
				{
					xtype: "button",
					text: "新增",
					iconCls: 'x-fa  fa-file-o',
					handler: 'add',
					margin: '0 10 0 10',
					// style: 'background-color:#108ee9; border-radius:4px;-webkit-border-radius: 4px;',
					style: 'border-radius:4px;-webkit-border-radius: 4px;'
				}
			],
			columns: [{
					header: '键值',
					dataIndex: 'value',
					/** editor: 'textfield' ,*/
					align: 'center',
					width: '20%'
				},
				{
					header: '标签',
					dataIndex: 'label',
					/** editor: 'textfield' ,*/
					align: 'center',
					width: '20%'
				},
				{
					header: '类型',
					dataIndex: 'type',
					/** editor: 'textfield' ,*/
					align: 'center',
					width: '20%'
				},
				{
					header: '描述',
					dataIndex: 'description',
					/** editor: 'textfield' ,*/
					align: 'center',
					width: '14.9%'
				},
				{
					header: '排序',
					dataIndex: 'sort',
					/** editor: 'textfield' ,*/
					align: 'center',
					width: '14.8%'
				},
				{
					header: '操作',
					dataIndex: 'operate',
					/** editor: 'textfield' ,*/
					align: 'center',
					xtype: 'actioncolumn',
					width: '10%',
					items: [{
						xtype: 'button',
						text: '修改',
						iconCls: "x-fa fa-edit",
						style: 'border-radius:4px;-webkit-border-radius: 4px;',
						handler: 'update'
					}, {
						xtype: 'button',
						text: '删除',
						iconCls: "x-fa fa-trash",
						style: 'border-radius:4px;-webkit-border-radius: 4px;',
						handler: 'delete'
					}]
				}

			],
			store: {
				type: 'dict'
			},
			bbar: [{
				xtype: "pagingtoolbar",
				store: {
					type: 'dict'
				},
				autoLoad: true,
				displayInfo: true,
				displayMsg: "显示从第{0}条数据到第{1}条数据，共{2}条数据",
				emptyMsg: "没有记录"
			}],
			stripeRows: true,
			columnLines: true,
			plugins: {
				ptype: 'cellediting',
				clicksToEdit: 1
			}
		}
	]
})

Ext.define('Admin.view.sys.DictAdd', {
	extend: 'Admin.common.form.BaseFormPanel',
	xtype: 'dictAdd',
	alias: 'dictAdd',
	columns: 2,
	defaults: {
		labelAlign: 'right',
	},
	items: [{
		xtype: 'textfield',
		name: 'value',
		fieldLabel: '键值名称',
		width: 500,
		colspan: 2
	}, {
		xtype: 'textfield',
		name: 'label',
		dicType: 'incidentType',
		fieldLabel: '标签'
	}, {
		xtype: 'textfield',
		name: 'type',
		labelWidth: 50,
		fieldLabel: '类型'
	}, {
		xtype: 'textfield',
		fieldLabel: '描述',
		name: 'description',
		width: 500,
		colspan: 2
	}, {
		xtype: 'textfield',
		fieldLabel: '排序',
		name: 'sort',
		width: 500,
		maxWidth: 500,
		colspan: 2
	}, {
		xtype: 'textarea',
		fieldLabel: '备注',
		name: 'remarks',
		width: 500,
		colspan: 2
	}]

});